package org.springblade.modules.repair.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.repair.entity.GroupRobotConfig;
import org.springblade.modules.repair.enums.ChatGroupRobotEnum;
import org.springblade.modules.repair.vo.GroupRobotConfigVO;
import org.springblade.modules.repair.mapper.GroupRobotConfigMapper;
import org.springblade.modules.repair.service.GroupRobotConfigService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
* @author Sharry
* @description 针对表【blade_group_robot_config(消息推送-群-机器人配置表)】的数据库操作Service实现
* @createDate 2023-10-09 16:43:13
*/
@Service
public class GroupRobotConfigServiceImpl extends ServiceImpl<GroupRobotConfigMapper, GroupRobotConfig>
    implements GroupRobotConfigService {


	/**
	 * 根据当前电梯 获取推送配置
	 * @param elevatorId 当前电梯
	 * @return 封装的结果
	 */
	@Override
	public List<GroupRobotConfigVO> getConfigByElevatorId(Long elevatorId){
		List<GroupRobotConfigVO> result = baseMapper.getConfigByElevatorId(elevatorId);
		if(Func.isNotEmpty(result)){
			result = result.stream()
				.filter(f -> f.getPushAllow().equals(ChatGroupRobotEnum.GROUP_PUSH_OPEN.getKey()))
				.collect(Collectors.toList());
		}
		return result;
	}

}
